package cn.snmp.mutual.uk.stack;

import java.util.*;
import java.io.*;

class AsnEncoderv2c extends AsnEncoderBase {
    private static final String version_id = "@(#)$Id: AsnEncoderv2c.java,v 3.3 2006/02/09 14:16:36 birgit Exp $ Copyright Westhawk Ltd";

    ByteArrayOutputStream EncodeSNMPv2c(final SnmpContextv2c context, final byte msg_type, final int pduId, final int errstat, final int errind, final Enumeration ve) throws IOException, EncodingException {
        final AsnSequence asnTopSeq = new AsnSequence();
        asnTopSeq.add(new AsnInteger(1));
        asnTopSeq.add(new AsnOctets(context.getCommunity()));
        final AsnObject asnPduObject = this.EncodePdu(msg_type, pduId, errstat, errind, ve);
        asnTopSeq.add(asnPduObject);
        if (AsnObject.debug > 10) {
            System.out.println("\n" + this.getClass().getName() + ".EncodeSNMPv2c(): ");
        }
        final ByteArrayOutputStream bout = new ByteArrayOutputStream();
        asnTopSeq.write(bout);
        return bout;
    }
}
